# 2、登录，账号密码从文件里面取
#     1、最多输入3次
#     2、账号/密码的为空校验
#     3、不存在要提示
#     4、登录成功结束

list = open('user.txt','r',encoding='utf-8')
read_list=list.read()
user_list=read_list.split()#以空格或者换行符分割读取的文件,分割之后成为新的list
user = {}
for i in user_list:
    account = i.split(':')[0]
    pwd = i.split(':')[1]
    user[account]=pwd

for i in range(3):
    account_input = input('请输入账号:').strip()
    pwd_input = input('请输入密码:').strip()

    if account_input == ''or pwd_input =='':
        print('账号密码不能为空')
    elif account_input not in user.keys():
        print('账号不存在,请重试!')
    elif account_input in user.keys() and pwd_input ==user[account_input]:
        print('登录成功'.center(50,'*'))
else:
    print('您已失败三次,账户已锁定')
